package cn.iocoder.yudao.module.mp.dal.mysql.template;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.mp.dal.dataobject.template.TemplateDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.mp.controller.admin.template.vo.*;

/**
 * 公众号模板 Mapper
 *
 * @author chenxx
 */
@Mapper
public interface TemplateMapper extends BaseMapperX<TemplateDO> {

    default PageResult<TemplateDO> selectPage(TemplatePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<TemplateDO>()
                .likeIfPresent(TemplateDO::getTemplateId, reqVO.getTemplateId())
                .likeIfPresent(TemplateDO::getTitle, reqVO.getTitle())
                .likeIfPresent(TemplateDO::getContent, reqVO.getContent())
                .likeIfPresent(TemplateDO::getExample, reqVO.getExample())
                .eqIfPresent(TemplateDO::getType, reqVO.getType())
                .eqIfPresent(TemplateDO::getAccountId, reqVO.getAccountId())
                .betweenIfPresent(TemplateDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(TemplateDO::getId));
    }

    default List<TemplateDO> selectList(TemplateExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<TemplateDO>()
                .eqIfPresent(TemplateDO::getTemplateId, reqVO.getTemplateId())
                .likeIfPresent(TemplateDO::getTitle, reqVO.getTitle())
                .likeIfPresent(TemplateDO::getContent, reqVO.getContent())
                .likeIfPresent(TemplateDO::getExample, reqVO.getExample())
                .eqIfPresent(TemplateDO::getAccountId, reqVO.getAccountId())
                .eqIfPresent(TemplateDO::getType, reqVO.getType())
                .betweenIfPresent(TemplateDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(TemplateDO::getId));
    }

}
